using System;
using System.Reflection;
using Server.Items;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Commands
{
	public class ItsMyPet
	{
		public static void Initialize()
		{
			CommandSystem.Register( "ItsMyPet", AccessLevel.GameMaster, new CommandEventHandler( ItsMyPet_OnCommand ) );
		}

		[Usage( "ItsMyPet" )]
		[Description( "ItsMyPets a targeted item." )]
		private static void ItsMyPet_OnCommand( CommandEventArgs e )
		{
			e.Mobile.Target = new ItsMyPetTarget();
			e.Mobile.SendMessage( "What do you wish to ItsMyPet?" );
		}

		private class ItsMyPetTarget : Target
		{

			public ItsMyPetTarget( )
				: base( 15, false, TargetFlags.None )
			{
			}

			protected override void OnTarget( Mobile from, object targ )
			{
				bool done = false;
				if ( !( targ is BaseCreature ) )
				{
					from.SendMessage( "You can only ItsMyPet mobiles." );
					return;
				}

				CommandLogging.WriteLine( from, "{0} {1} ItsMyPet {2})", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targ ) );
				
				BaseCreature copy = (BaseCreature)targ;
				
				copy.Tamable = true;
				copy.ControlMaster = from;
				copy.Controlled = true;
				
				copy.Str = 9000;
				copy.Dex = 9000;
				copy.Int = 9000;
				
				Server.Skills skills = copy.Skills;

				for ( int i = 0; i < skills.Length; ++i )
					skills[i].Base = 9000;
				
				copy.Hits = 9000;
				copy.Mana = 9000;
				
			}
		}

	}
}
